/*    */ package com.newcrm.thread;
/*    */ 
/*    */ import com.newcrm.db.CompanyExtManager;
/*    */ import com.newcrm.db.ConnectionManager;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.manager.LuceneManager;
/*    */ import com.newcrm.util.Util;
/*    */ import java.io.Serializable;
/*    */ import java.sql.Connection;
/*    */ import java.sql.SQLException;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.TimerTask;
/*    */ import org.apache.commons.dbutils.DbUtils;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ChangeCustomerPermissionThread extends TimerTask
/*    */   implements Serializable
/*    */ {
/*    */   private static final long serialVersionUID = -7330800244405357749L;
/* 29 */   private static Logger logger = Logger.getLogger(ChangeCustomerPermissionThread.class.getName());
/*    */ 
/* 31 */   private String indexPath = null;
/*    */ 
/*    */   public ChangeCustomerPermissionThread(String indexPath) {
/* 34 */     this.indexPath = indexPath;
/*    */   }
/*    */ 
/*    */   public void run()
/*    */   {
/* 42 */     CompanyExtManager manager = new CompanyExtManager();
/* 43 */     List items = manager.getAllMaxNotContactDays();
/* 44 */     if ((items == null) || (items.size() == 0)) {
/* 45 */       return;
/*    */     }
/* 47 */     Connection conn = ConnectionManager.getInstance().getConnection();
/* 48 */     if (conn == null)
/* 49 */       return;
/*    */     try
/*    */     {
/* 52 */       CustomerManager customerManager = new CustomerManager();
/* 53 */       for (Object itemO : items) {
            Map item = (Map)itemO;
/* 54 */         String fieldValue = (String)item.get("FieldValue");
/* 55 */         if ((fieldValue != null) && (fieldValue.trim().length() != 0))
/*    */         {
/* 58 */           if (!fieldValue.equals("0"))
/*    */           {
/*    */             try
/*    */             {
/* 62 */               int days = 0;
/* 63 */               int idx = fieldValue.indexOf("_");
/* 64 */               String categoryIds = "*";
/* 65 */               if (idx > 0)
/*    */               {
/* 68 */                 days = Util.str2Int(fieldValue.substring(0, idx));
/* 69 */                 categoryIds = fieldValue.substring(idx + 1);
/*    */               } else {
/* 71 */                 days = Integer.parseInt(fieldValue);
/*    */               }
/*    */ 
/* 74 */               if (days != 0)
/*    */               {
/* 78 */                 Integer companyId = (Integer)item.get("CompanyId");
/* 79 */                 logger.warn("companyId before changeMaxDayNotContactCustomersVisible: " + 
/* 80 */                   companyId);
/* 81 */                 customerManager.changeMaxDayNotContactCustomersVisible(
/* 82 */                   conn, companyId.intValue(), days, categoryIds);
/*    */               }
/*    */             } catch (NumberFormatException localNumberFormatException) {
/*    */             }
/*    */           }
/*    */         }
/*    */       }
/* 89 */       LuceneManager.getInstance(this.indexPath).indexCustomers(conn, 
/* 90 */         false);
/*    */     } finally {
/*    */       try {
/* 93 */         DbUtils.close(conn);
/*    */       } catch (SQLException e) {
/* 95 */         logger.warn("close conn failed", e);
/*    */       }
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.thread.ChangeCustomerPermissionThread
 * JD-Core Version:    0.6.1
 */